<template>
<el-dialog :model-value="visible" title="牙齿评估信息">
    <el-descriptions
        title="病变等级"
        direction="vertical"
        column="7"
        size="default"
        style="margin-bottom: 30px"
        border>
        <el-descriptions-item v-for="item in items" :label="item.label">
            {{item.result}}
        </el-descriptions-item>
    </el-descriptions>
    <span>
        <el-button
            type="primary"
            style="font-size: 16px"
            text>
            下载原始模型
        </el-button>
    </span>
    <span>
        <el-button
            type="primary"
            style="font-size: 16px"
            text>
            下载分割模型
        </el-button>
    </span>
</el-dialog>
</template>

<script>
import axios from 'axios';
export default {
    name: "TeethDetailPage",
    props: ['visible', 'id'],
    data() {
        return {
            i_d: 1,
            results: [1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4, 3, 2, 1],
            type: 'upper'
        }
    },
    computed: {
        labels: function () {
            if (this.type === 'upper') {
                return ['UL1', 'UL2', 'UL3', 'UL4', 'UL5', 'UL6', 'UL7',
                    'UR1', 'UR2', 'UR3', 'UR4', 'UR5', 'UR6', 'UR7']
            } else {
                return ['LL1', 'LL2', 'LL3', 'LL4', 'LL5', 'LL6', 'LL7',
                    'LR1', 'LR2', 'LR3', 'LR4', 'LR5', 'LR6', 'LR7']
            }
        },
        items: function () {
            let labels = this.labels
            let results = this.results

            let items = []
            for (let i = 0; i < results.length; i++) {
                items.push({
                    label: labels[i],
                    result: results[i]
                })
            }

            return items
        }
    },
    watch: {
        id: function (newData, oldData) {
            this.i_d = newData
            this.getData()
        }
    },
    methods: {
        getData: function () {
            const _this = this
            axios.get(process.env.VUE_APP_BASEURL + 'teeth/teethById?id=' + _this.i_d).then(function (resp) {
                if (resp.data.code == 0) {
                    console.log(resp.data.data)
                    _this.results = resp.data.data.results
                    _this.type = resp.data.data.type
                }
            })
        }
    },
    mounted() {
        this.getData()
    }
}
</script>

<style scoped>

</style>